exp07.ShowMainLayer02 = cc.Layer.extend({
	lead:null,
	real:null,
	curIndex: 0,
	ctor:function () {
		this._super();
		this.init();
		this.turnmenu();
		this.scheduleUpdate();
		return true;
	},
	init:function(){
		this.pageView = new ccui.PageView();//建立pageview
		this.pageView.setSwallowTouches(false);
		this.pageView.setContentSize(cc.size(980, 600));
		this.pageView.setPosition(640,338);
		this.pageView.setAnchorPoint(0.5,0.5);
		this.addChild(this.pageView);
		
		this.layout1 = new ccui.Layout();//第一页
		this.layout1.setContentSize(cc.size(980, 600));
		this.pageView.addPage(this.layout1);
		
		this.label1 = new cc.LabelTTF("1.热是一种能量的形式,这种能量的性质与物体的内部分子运动相关" +
				"\n2.分子间存在着吸引与排斥的相互作用,所以分子又具有势能。物质内部所" +
				"\n  有分子做无规则运动的动能和分子间作用力的势能之和,称为物质的内能" +
				"\n3.物质内能是描述物体内部大量分子热运动的能量,包括他们的动能和势能" +
				"\n4.物体温度升高,分子的热运动加快,表明内能增大;物体的温度降低,分子的" +
				"\n  热运动减慢,表明内能减小",gg.fontName,gg.fontSize4);
		this.label1.setPosition(this.layout1.width/2,this.layout1.height-this.label1.height/2);
		this.layout1.addChild(this.label1);	

//		this.hongxi = new Angel(this.layout1, "#hongxi.png",this.callback,this);
//		this.hongxi.setScale(0.8,0.7);
//		this.hongxi.setPosition(400,250);
//
//		this.playbutton(cc.p(650,350));//展示按钮
						
		this.layout2 = new ccui.Layout();//第二页
		this.layout2.setContentSize(cc.size(980, 600));
		this.pageView.addPage(this.layout2);
		
		this.hongxi1 = new cc.Sprite("#neineng.png");
		this.hongxi1.setScale(0.8,0.7);
		this.hongxi1.setPosition(490,this.layout2.height - this.hongxi1.height/2+150);
		this.layout2.addChild(this.hongxi1,5);	


		var text2 = $.format("　　物体的内能也与体积和形状有关，物体的体积和形状改变时,使物体内部分子间的相互作用力及相对位置发生改变,从而使分子势能变化," +
				"也就引起内能的变化。物体的内能还与物体内所含的分子数,即物质多少有关,所以高温的物体的内能未必比低温物体的多", 980,30);
		this.label2 = new cc.LabelTTF(text2,gg.fontName,gg.fontSize4);
		$.down(this.hongxi1,this.label2,20);
		//this.label2.setPosition(640,160);
		this.layout2.addChild(this.label2);	
		
		
		this.layout3 = new ccui.Layout();//第三页
		this.layout3.setContentSize(cc.size(1200, 600));
		this.pageView.addPage(this.layout3);
		
		var text3 = $.format("　　做功可以改变物体的内能。" +
				"热传递有三种方式:热传导是通过导热物体的对热量的传递" +
				"对流是通过气体或液体的流动对热量的传递" +
				"热辐射是通过电磁辐射对热量的传递" +
				"通过大连给的实验与分析可见,做功和热传递都能改变物体的内能," +
				"这是改变物体内能的两种途径.做功和热传递在改变物体内能上是等效的," +
				"我们无法根据结果判断内能改变的原因", 1200,30);
		this.label3 = new cc.LabelTTF(text3,gg.fontName,gg.fontSize4);
		this.label3.setPosition(this.layout3.width/2,this.layout3.height-this.label3.height/2);		
		this.layout3.addChild(this.label3);	
		
		

		this.map=new cc.Sprite("#map.png");
		this.map.setPosition(cc.p(250,230));
		this.layout3.addChild(this.map);
		
		for(var i=1;i<4;i++){
			var str="right"+i;
			this.str=new cc.Sprite("#red.png");
			this.str.setPosition(cc.p(this.map.width*(0.3+(i-1)*0.2), this.map.height*0.85));
			this.map.addChild(this.str);
		}
		
		this.down=new cc.Sprite("#red.png");
		this.down.setRotation(90);
		this.down.setPosition(cc.p(this.map.width*0.75, this.map.height*0.65));
		this.map.addChild(this.down);
		
		for(var i=1;i<4;i++){
			var str1="left"+i;
			this.str1=new cc.Sprite("#blue.png");
			this.str1.setPosition(cc.p(this.map.width*(0.3+(i-1)*0.2), this.map.height*0.45));
			this.map.addChild(this.str1);
		}
		
		this.up=new cc.Sprite("#blue.png");
		this.up.setRotation(90);
		this.up.setPosition(cc.p(this.map.width*0.25, this.map.height*0.65));
		this.map.addChild(this.up);

		
		this.map1=new cc.Sprite("#map1.png");
		this.map1.setPosition(cc.p(740, 230));
		this.layout3.addChild(this.map1);
		
		for(var i=1;i<4;i++){
			var str2="right"+i;
			this.str2=new cc.Sprite("#blue.png");
			this.str2.setPosition(cc.p(this.map1.width*(0.3+(i-1)*0.2), this.map1.height*0.85));
			this.map1.addChild(this.str2);
		}

		this.down1=new cc.Sprite("#blue.png");
		this.down1.setRotation(90);
		this.down1.setPosition(cc.p(this.map1.width*0.75, this.map1.height*0.65));
		this.map1.addChild(this.down1);

		for(var i=1;i<4;i++){
			var str3="left"+i;
			this.str3=new cc.Sprite("#red.png");
			this.str3.setPosition(cc.p(this.map1.width*(0.3+(i-1)*0.2), this.map1.height*0.45));
			this.map1.addChild(this.str3);
		}

		this.up1=new cc.Sprite("#red.png");
		this.up1.setRotation(90);
		this.up1.setPosition(cc.p(this.map1.width*0.25, this.map1.height*0.65));
		this.map1.addChild(this.up1);
		
		this.yuanliButton = new Angel(this.layout3,"#unsel.png",this.callback,this);
		this.yuanliButton.setScale(0.3,0.5);
		this.yuanliButton.setPosition(35,50);
		var label = new cc.LabelTTF("原理:",gg.fontName,50);
		label.setPosition(this.yuanliButton.width/2,this.yuanliButton.height/2);
		this.yuanliButton.addChild(label);
		

//		var text4 = $.format("　　因为高山地区空气稀薄，大气压强低，人们呼吸时吸入的氧气的分压也低，造成肺泡中的氧" +
//				"分压降低，血液中含量减少。从而使人的神经系统、呼吸系统和心血管系统出现障碍。", 980,30);
//		this.label4 = new cc.LabelTTF(text4,gg.fontName,gg.fontSize4);
//		this.label4.setPosition(490,160);
//		this.label4.setVisible(false);
//		this.layout3.addChild(this.label4);	
	},	
	turnmenu:function(){
		this.turnleft = new ButtonScale(this,res_public.leftbutton,this.callback);
		this.turnleft.setPosition(80,376-50);
		this.turnleft.setVisible(false);       
		this.turnright = new ButtonScale(this,res_public.rightbutton,this.callback);
		this.turnright.setPosition(1200,376-50);   	    	
	},
	playbutton:function(pos){
		this.play = new Angel(this.layout1,"#unsel.png",this.callback,this);
		this.play.setScale(0.3,0.5);
		this.play.setPosition(pos);
		this.play.setEnable(true);
		var label = new cc.LabelTTF("点击",gg.fontName,50);
		label.setPosition(this.play.width/2,this.play.height/2);
		this.play.addChild(label);
	},
	update:function(){//用pageview翻页暂时没找到好的更新方法
		var index = this.pageView.getCurPageIndex();//获取当前页，以0 1 2 形式
		if(this.curIndex != index){
			if(index == 0){//当从第二页滑到第一页时，继续左滑，左滑按钮隐藏（滑到第一页）
				this.turnleft.setVisible(false);
				this.turnright.setVisible(true);
			}else if(index == 2){//当从第倒数第二页滑到最后页时，继续右滑，右滑按钮隐藏，根据自己创建的页数，手动调整（滑到最后页）
				this.turnleft.setVisible(true);
				this.turnright.setVisible(false);
			}else{
				this.turnleft.setVisible(true);
				this.turnright.setVisible(true);
			}  
			this.curIndex = index;
		}			
	},
	callback:function(p){
		switch(p){		
		case this.turnleft:
			var index = this.pageView.getCurPageIndex();
			this.pageView.scrollToPage(index - 1);
		    break;
		case this.turnright:
			var index = this.pageView.getCurPageIndex();			
			this.pageView.scrollToPage(index + 1);
			break;
//		case this.play:
//			p.setSpriteFrame("sel.png");
//			p.setEnable(false);
//			var scale = cc.scaleTo(1,0.5);
//			var scale1 = cc.scaleTo(1,0.8,0.7);
//			var seq = cc.sequence(scale,scale1,cc.callFunc(function(){
//				p.setSpriteFrame("unsel.png");
//				p.setEnable(true);
//			},this)); 
//			this.hongxi.runAction(seq);
//			break;
		case this.yuanliButton:
			p.setSpriteFrame("sel.png");
			p.setEnable(false);
			this.label4.setVisible(true);
		break;
		}
	}
	
});
